package com.copm.demonstrationsystem.controller.introductionfeatures;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.commons.util.ControllerUtils;
import com.copm.demonstrationsystem.service.introductionfeatures.CompanyHonorService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: Yuan Baiyu
 * @Date: Created in 0:07 2018/4/17
 */

@RestController
@RequestMapping("/honor")
@CrossOrigin
public class CompanyHonorController {

    @Autowired
    CompanyHonorService companyHonorService;

    //获取“品牌荣誉”页面信息
    @ApiOperation("品牌荣誉 页面信息的获取接口")
    @GetMapping()
    public ResponseStatus getPage() {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.getCompanyHonor());
    }

    //添加“品牌荣誉”页面文字
    @ApiOperation("品牌荣誉 页面文本内容的添加接口")
    @ApiImplicitParam(name = "introduction",value = "文本内容"
            ,dataType = "String",paramType = "query",required = true)
    @PostMapping("/text")
    public ResponseStatus addText(@RequestParam("introduction") String introduction) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.addCompanyHonorText(introduction));
    }

    //添加“品牌荣誉”页面图片
    @ApiOperation("品牌荣誉 页面图片添加接口")
    @ApiImplicitParam(name = "file",value = "图片信息"
            ,dataType = "file",paramType = "form",required = true)
    @PostMapping("/image")
    public ResponseStatus addImage(@RequestPart("file") MultipartFile file) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.addCompanyHonorImage(file));
    }

    //删除“品牌荣誉”页面文字
    @ApiOperation("品牌荣誉 页面文字删除接口")
    @ApiImplicitParam(name = "id",value = "待删除文字id"
            ,dataType = "Long",paramType = "path",required = true)
    @DeleteMapping("/text/{id}")
    public ResponseStatus deleteText(@PathVariable("id") Long id) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.deleteCompanyHonorText(id));
    }

    //删除“品牌荣誉”页面图片
    @ApiOperation("品牌荣誉 页面图片删除接口")
    @ApiImplicitParam(name = "id",value = "待删除图片id"
            ,dataType = "Long",paramType = "path",required = true)
    @DeleteMapping("/image/{id}")
    public ResponseStatus deleteImage(@PathVariable("id") Long id) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.deleteCompanyHonorImage(id));
    }

    //修改“品牌荣誉”页面文字
    @ApiOperation("品牌荣誉 页面文字修改接口")
    @ApiImplicitParams({ @ApiImplicitParam(name = "id",value = "待修改文字ID"
            ,dataType = "Long",paramType = "path",required = true),
            @ApiImplicitParam(name = "introduction",value = "文本内容"
            ,dataType = "String",paramType = "query",required = true)})
    @PutMapping("/text/{id}")
    public ResponseStatus modifyText(@PathVariable("id") Long id,@RequestParam("introduction") String introduction){
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.modifyCompanyHonorText(id,introduction));
    }

    //修改“品牌荣誉”页面背景图片
    @ApiOperation("品牌荣誉 页面背景图片修改接口")
    @PostMapping("/backgroundimage")
    public ResponseStatus modifyImage(@RequestPart("file") MultipartFile file){
        return  ControllerUtils.fillResponse(new ResponseStatus(),
                companyHonorService.modifyCompanyHonorBackgroundImage(file));
    }



//    //修改“品牌荣誉”页面图片
//    @PutMapping("/image/{id}")
//    @ApiOperation("品牌荣誉 页面文字修改接口")
//    @ApiImplicitParams({ @ApiImplicitParam(name = "id",value = "原图片id"
//            ,dataType = "Long",paramType = "path",required = true),
//            @ApiImplicitParam(name = "file",value = "图片信息"
//                    ,dataType = "file",paramType = "form",required = true)})
//    public ResponseStatus modifyImage(@PathVariable("id") Long id, @RequestPart("file") MultipartFile file){
//        return  ControllerUtils.fillResponse(new ResponseStatus(),
//                companyHonorService.modifyCompanyHonorImage(id,file));
//    }


    //
//    //删除“品牌荣誉”页面背景图片
//    @ApiOperation("品牌荣誉 页面背景图片删除接口")
//    @DeleteMapping("/backgroundimage")
//    public ResponseStatus deleteBackgroundImage() {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                companyHonorService.deleteCompanyHonorBackgroundImage());
//    }

//    //添加“品牌荣誉”页面背景图片
//    @ApiOperation("品牌荣誉 页面背景图片添加接口")
//    @ApiImplicitParam(name = "file",value = "图片信息"
//            ,dataType = "file",paramType = "form",required = true)
//    @PostMapping("backgroundimage")
//    public ResponseStatus addBackgroundImage(@RequestPart("file") MultipartFile file) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                companyHonorService.addCompanyHonorBackgroundImage(file));
//    }

}
